package com.juzipi.demo.handler;


import com.juzipi.demo.tools.Result;
import com.juzipi.demo.tools.ResultTool;
import com.juzipi.demo.utils.JsonAuthentication;
import com.juzipi.demo.utils.ResultCode;
import org.springframework.security.web.session.InvalidSessionStrategy;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 登陆超时
 */

@Component
public class MyInvalidSessionStrategy extends JsonAuthentication implements InvalidSessionStrategy {


    @Override
    public void onInvalidSessionDetected(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
        Result result = ResultTool.failCustomize(ResultCode.USER_SESSION_INVALID, null);

        this.WriteJson(httpServletRequest,httpServletResponse,result);
    }

}
